package demo;

public class OperationFactory {

    public static Operation getOperation(String operation) {
        Operation opr = null;
        switch (operation) {
            case "+":
                opr = new OperationAdd();
                break;
            case "-":
                opr = new OperationSub();
                break;
            case "*":
                opr = new OperationMul();
                break;
            case "/":
                opr = new OperationDiv();
                break;
            default:
                throw new RuntimeException("不支持该操作！");
        }
        return opr;
    }
}
